#include "dsk.h"
#include "fmt_prt.h"
#include "module.h"

void dfl_write_sector(uint32_t sector, void* buf, uint32_t count)
{
    fmt_printf("%s: sector = %u, count = %u\n", __func__, sector, count);
}

void dfl_read_sector(uint32_t sector, void* buf, uint32_t count)
{
    fmt_printf("%s: sector = %u, count = %u\n", __func__, sector, count);
}

uint32_t dfl_get_sector_size()
{
    fmt_printf("%s: sector_size = 512\n", __func__);
    return 512;
}

uint32_t dfl_get_dsk_size()
{
    fmt_printf("%s: dsk size = 32 M\n", __func__);
    return 32 * 1024 * 1024;
}

static struct dsk_ops_struct dfl_dsk_ops = {
    .get_sector_size = dfl_get_sector_size,
    .get_dsk_size = dfl_get_dsk_size,
    .read_sector = dfl_read_sector,
    .write_sector = dfl_write_sector,
};


void init_dfl_dsk()
{
    struct dsk_obj_struct* dsk_obj;

    dsk_obj = create_dsk_obj();
    if(!dsk_obj) {
        //
        fmt_printf("%s: create_dsk_obj failed\n", __func__);
        return;
    }

    dsk_obj->type = DFL_DSK;
    dsk_obj->ops = &dfl_dsk_ops;
    register_dsk_obj(dsk_obj);
}

module_init(init_dfl_dsk);